<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%
    Integer surveyId = input.getInt("survey_id", -1);
    List<Survey> surveys = QBuilder.db("basedb").select().from("Survey").where(new Where("status = ", STATUS_ENABLE).and("id=", surveyId).and("belong=", "ys"+ token.getUid())).query().getResultObj();
    List<SurveyQuestion> sqs = QBuilder.db("basedb").select().from("SurveyQuestion").where(new Where("status = ", STATUS_ENABLE).and("surveyId=", surveyId)).query().getResultObj();
    if (isEmpty(surveys) || isEmpty(sqs)) {
        msg = new Message(30050, "删除失败");
        Tools.encryptPrint(out, msg);
        return;
    }
    for (int i = 0; i < surveys.size(); i++) {
        Survey survey = surveys.get(i);
        survey.setStatus(STATUS_DISABLE);
    }
    for (int i = 0; i < sqs.size(); i++) {
        SurveyQuestion sq = sqs.get(i);
        sq.setStatus(STATUS_DISABLE);
    }
    DBTools.db("basedb").modItem(surveys);
    DBTools.db("basedb").modItem(sqs);
    Tools.encryptPrint(out, msg);
%>
